import { fileURLToPath, URL } from 'node:url';

import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';

// https://vitejs.dev/config/
export default defineConfig({
    server: {
        host: '0.0.0.0',
        port: 3333,
        proxy: {
            '/marketapi': {
                target: 'http://192.168.10.200/marketapi',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/marketapi/, ''),
            },
            '/images': {
                target: 'http://192.168.10.253:8080/upload',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/images/, ''),
            },
        },
    },
    preview: {
        host: '0.0.0.0',
        port: 3334,
        proxy: {
            '/marketapi': {
                target: 'http://192.168.10.200/marketapi',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/marketapi/, ''),
            },
        },
    },
    plugins: [vue(), vueJsx()],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url)),
        },
    },
    build: {
        outDir: 'Mobile phone conversation frame',
    },
});
